//
//  FKGoodsFilterCell.m
//  WanTao
//
//  Created by Macbook Pro on 2019/3/20.
//  Copyright © 2019 Macbook Pro. All rights reserved.
//

#import "FKGoodsFilterCell.h"

@interface FKGoodsFilterCell ()

@property (nonatomic, weak) UILabel *titleLabel;
@property (nonatomic, weak) UIImageView *iconView;

@end

@implementation FKGoodsFilterCell

- (void)setupSubviews
{
    [super setupSubviews];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    UILabel *titleLabel = [UILabel fk_labelWithFont:fk_adjustFont(15) textColor:fkColor333333];
    [self.contentView addSubview:titleLabel];
    self.titleLabel = titleLabel;
    
    UIImageView *iconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"check"]];
    [self.contentView addSubview:iconView];
    self.iconView = iconView;
    
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(12);
        make.centerY.offset(0);
    }];
    [iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-12);
        make.centerY.equalTo(titleLabel);
    }];
}

- (void)setData:(id)data
{
    [super setData:data];
    
    self.titleLabel.text = data[@"name"];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    self.titleLabel.textColor = selected ? fkMainColor : fkColor333333;
    if (self.isCanShowIcon) {
        self.iconView.hidden = !selected;
    } else {
        self.iconView.hidden = true;
    }
}

@end
